package main

import (
	"flag"
	"os"
	"runtime"
	"strconv"

	log "github.com/sirupsen/logrus"

	"github.com/xdhuxc/asset-management-system/src/api"
	"github.com/xdhuxc/asset-management-system/src/conf"
)

var cnf = flag.String("conf", "conf.test.yaml", "configuration file path")

func init() {
	cs := os.Getenv("CPUS")
	if cpus, err := strconv.Atoi(cs); err == nil {
		runtime.GOMAXPROCS(cpus)
	} else {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}
}

func main() {
	flag.Parse()
	if err := conf.InitConfiguration(*cnf); err != nil {
		log.Fatalf("Init config error: %v", err)
	}

	app := api.NewRouter()

	if err := app.Run(); err != nil {
		log.Fatal(err)
	}

}
